package com.ys.controller.web.sys;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ys.config.MenuId;
import com.ys.entity.sys.YsGrid;
import com.ys.entity.sys.YsGridCol;
import com.ys.service.sys.CommonApiService;
import com.ys.service.sys.YsGridColService;
import com.ys.vo.W;

/**
 * 
 * @author Jason
 *
 */
@Controller
@RequestMapping("/web/sys/ysGridCol")
public class WebYsGridColController {
	
	@Autowired
	private CommonApiService<YsGridCol> commonApiService;
	
	@Autowired
	private YsGridColService ysGridColService;
	
	/**
	 * 新增
	 * @throws Exception 
	 */
	@GetMapping("/toAdd")
	public String toAdd(Model model, Long gridId) throws Exception{
		
		if (gridId == null) {
			return W.error(model, "所属子列表ID不能为空");
		}
		Map<String, Object> extraParam = new HashMap<String, Object>();
		YsGrid ysGrid = new YsGrid().setId(gridId).queryFirst();
		extraParam.put("nameGrid", ysGrid.getName());
		
		YsGridCol entity = new YsGridCol()
				.setGridId(gridId)
				.setFrontWidth(120);
		
		return commonApiService.toAdd(model, entity, MenuId.YS_GridCol, extraParam, null);
	}
	
//	/**
//	 * 设置
//	 */
//	@GetMapping("/toSettingGrid")
//	public String toSettingGrid(Model model, Long id){
//		return ysGridColService.toSetting(model, id);
//	}
	
	/**
	 * 选项配置
	 */
	@GetMapping("/toSettingOption")
	public String toSettingOption(Model model, Long id){
		return ysGridColService.toSettingOption(model, id);
	}
	
	/**
	 * 弹出框配置
	 */
	@GetMapping("/toSettingSelectorModal")
	public String toSettingSelectorModal(Model model, Long id){
		return ysGridColService.toSettingSelectorModal(model, id);
	}
	
	/**
	 * 设置多文件控件的类型
	 */
	@GetMapping("/toSettingMultyFileSourceType")
	public String toSettingMultyFileSourceType(Model model, Long id){
		return ysGridColService.toSettingMultyFileSourceType(model, id);
	}
}
